package Demo;

class Login{
    private String name;
    private String password;

    public Login(String name, String password) {
        this.name = name;
        this.password = password;
    }
    public void login(String name,String password){
        if(!this.name.equals(name)){
            throw new NameException("用户名异常");
        }else if(!this.password.equals(password)){
            throw new PasswordException("密码异常");
        }
        System.out.println("登录成功");
    }
}
public class Test {
    public static void main(String[] args) {
        Login login=new Login("lebron james","236");
        try{
            login.login("lebron james","236");
        }catch (NameException e){
            e.printStackTrace();
        }catch (PasswordException e){
            e.printStackTrace();
        }
    }
}
